package com.atwu.wl2022.service.impl;

import com.atwu.wl2022.entity.Article;
import com.atwu.wl2022.mapper.ArticleMapper;
import com.atwu.wl2022.service.IArticleService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 这是文章信息表，记录博客中所有文章 服务实现类
 * </p>
 *
 * @author wule
 * @since 2022-06-12
 */
@Service
public class ArticleServiceImpl extends ServiceImpl<ArticleMapper, Article> implements IArticleService {

	@Autowired
	ArticleMapper articleMapper;

	@Override
	public List<Article> getMostPopularArticles() {
		return articleMapper.getMostPopularArticles();
	}

	@Override
	public List<Article> getArticlesByType(int articleType) {
		return articleMapper.getArticlesByType(articleType);
	}

	@Override
	public List<Article> getMostPopularArticlesByType(int articleType) {
		return articleMapper.getMostPopularArticlesByType(articleType);
	}

	@Override
	public Article queryArticleSelectImage(int id) {
		return articleMapper.selectOne(new QueryWrapper<Article>().select("image").eq("id",id));
	}


}
